﻿using System.Data;

namespace DAL
{
    public static class DalBarCode
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetBarCode(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_BarCode_Get");
        }
        public static DataTable GetBarCodeEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_BarCode", id);
            return Cls.GetData("sp_BarCode_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtBarCode obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@EncodeType", obj.EncodeType);
            Cls.AddParameter("@BarCode", obj.BarCode);
            Cls.AddParameter("@GenerateLabel", obj.GenerateLabel);
            Cls.AddParameter("@ImageFormat", obj.ImageFormat);
            Cls.AddParameter("@ImagesPath", obj.ImagesPath);
            Cls.AddParameter("@Width", obj.Width);
            Cls.AddParameter("@Height", obj.Height);
            Cls.AddParameter("@Alignment", obj.Alignment);
            Cls.AddParameter("@Backcolor", obj.Backcolor);
            Cls.AddParameter("@Forecolor", obj.Forecolor);
            return Cls.ExecuteNonQuery("sp_BarCode_Insert");
        }
        public static bool Update(EtBarCode obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_BarCode", obj.ID_BarCode);
            Cls.AddParameter("@EncodeType", obj.EncodeType);
            Cls.AddParameter("@BarCode", obj.BarCode);
            Cls.AddParameter("@GenerateLabel", obj.GenerateLabel);
            Cls.AddParameter("@ImageFormat", obj.ImageFormat);
            Cls.AddParameter("@ImagesPath", obj.ImagesPath);
            Cls.AddParameter("@Width", obj.Width);
            Cls.AddParameter("@Height", obj.Height);
            Cls.AddParameter("@Alignment", obj.Alignment);
            Cls.AddParameter("@Backcolor", obj.Backcolor);
            Cls.AddParameter("@Forecolor", obj.Forecolor);
            return Cls.ExecuteNonQuery("sp_BarCode_Update");
        }
        public static bool Delete(EtBarCode obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_BarCode", obj.ID_BarCode);
            return Cls.ExecuteNonQuery("sp_BarCode_Delete");
        }
        #endregion
    }
    public class EtBarCode
    {
        public int ID_BarCode { get; set; }
        public string EncodeType { get; set; }
        public string BarCode { get; set; }
        public bool GenerateLabel { get; set; }
        public string ImageFormat { get; set; }
        public string ImagesPath { get; set; }
        public string Width { get; set; }
        public string Height { get; set; }
        public string Alignment { get; set; }
        public string Backcolor { get; set; }
        public string Forecolor { get; set; }
    }
}